﻿<%@ Page Language="C#" AutoEventWireup="true"  Inherits="ZX.WebApp.forum.ThreadPage" MasterPageFile="~/forum/forum.Master"  %>
<asp:Content ContentPlaceHolderID="Top" ID="pageTop" runat="server">
<a href="board.aspx?">中旭论坛</a>    
    <% string _BoardID = this.GetStringFromQueryString("boardID", ""); %>
</asp:Content>
<asp:Content ContentPlaceHolderID="head" ID="pageHead" runat="server">
<script language="javascript" type="text/javascript">
    function Post() {
        parent.PostForumPost("/Extend/AutoloadForm.aspx?entity=forumPost&boardID=<%=this.GetStringFromQueryString("boardID", "") %>&r="+Math.random(), fn,this);
    }
    function fn()
    {
         this.location="/forum/Thread.aspx?boardID=<%=this.GetStringFromQueryString("boardID", "") %>&r="+Math.random();
         //alert("");
    }
</script>
</asp:Content>

<asp:Content ContentPlaceHolderID="Content" ID="pageContent" runat="server">
    <%
    ZX.BLL.Extend.BaseBussnies bll = new ZX.BLL.Extend.BaseBussnies();
    string _BoardID = this.GetStringFromQueryString("boardID", "");
    string _PageIndex = this.GetStringFromQueryString("page", "0");
    string _strSql = "SELECT TOP 25 * FROM  (  SELECT ROW_NUMBER() OVER(Order by AddTime Desc) AS RowNumber,* FROM V_forumThread  where boardID='{0}') a  WHERE  RowNumber > {1} * 25";
    System.Data.DataTable dt = bll.GetDataBySqlComm(string.Format(_strSql,_BoardID,_PageIndex));

    System.Data.DataTable _dt = bll.GetDataBySqlComm(string.Format("select count(*)  as C from forumThread  where boardID='{0}'", _BoardID));   
     int iCount = System.Int32.Parse(_dt.Rows[0].ItemArray[0].ToString());
     int iPage = iCount/25;
     iPage = iPage+(iCount%25>0?0:1);
  %>
  <div style=" margin:5px;width:100%">
  <%for (int _i = 0; _i < iPage+1; _i++)
    {%>
  <span style=" margin:2px; text-align:center; float:left;width:18px;height:18px; border:1px solid #DDD;"><a href="Thread.aspx?boardID=<%=_BoardID %>&page=<%=_i %>"><%=_i+1 %></a></span>
  <%} %><button id="btnNewPost" onclick="javascript:Post();" style="float:right; margin-right:10px;">发新贴</button></div>
    <table style="width:100%" id="ThreadList" cellpadding=0 cellspacing=0 border=1 >
    <thead><tr><th style="width:15px;">序号</th><th   style="width:380px;">主题</th><th style="width:90px;">时间</th><th style="width:120px">发贴人</th><th style="width:20px;">回复</th></tr></thead>
    <%
        if (dt != null)
        {
            int i = 0;
            foreach (System.Data.DataRow row in dt.Rows)
            {
                string BoardName = row.ItemArray[3].ToString();
                string Date = row.ItemArray[5].ToString();
                object _userID = row.ItemArray[dt.Columns["AddUser"].Ordinal] ;//== null ? System.Guid.Empty.ToString() : row.ItemArray[6].ToString();
                string id = row.ItemArray[1].ToString();
                %>
                <tr><td class="row<%=i%>"><%=row.ItemArray[0].ToString()%></td><td><a href="ViewPost.aspx?boardID=<%=_BoardID %>&threadID=<% =id %>"><%=BoardName%></a></td><td><% = Date%></td><td align="right"><% =row.ItemArray[dt.Columns["CName"].Ordinal].ToString() %>(<% =row.ItemArray[dt.Columns["PostName"].Ordinal].ToString() %>)</td><td><%=row.ItemArray[dt.Columns["Num"].Ordinal].ToString() %></td></tr>
                <%
                    i = i == 0 ? 1 : 0;
            }
        }
 %></table>
 <%
     //dt = bll.GetDataBySqlComm(string.Format("select count(*)  as C from forumThread  where boardID='{0}'",_BoardID));
     //iCount = System.Int32.Parse(dt.Rows[0].ItemArray[0].ToString());
     //iPage = iCount/25;
     //iPage = iPage+(iCount%25>0?0:1);
  %>
  
  <%for (int _i = 0; _i < iPage+1; _i++)
    {%>
  <div style=" margin:5px;widht:100%">
  <span style=" margin:2px; text-align:center; float:left;width:18px;height:18px; border:1px solid #DDD;"><a href="Thread.aspx?boardID=<%=_BoardID %>&page=<%=_i %>"><%=_i+1 %></a></span>
  
  </div>
  <%} %>
 </asp:Content>